﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;


namespace lcs.Web.Admin.TimeLine
{
    public partial class index : System.Web.UI.Page
    {
        Maticsoft.BLL.project bll = new Maticsoft.BLL.project();
        Maticsoft.BLL.supplyPlan bs = new Maticsoft.BLL.supplyPlan();
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!Page.IsPostBack)
            //{
            //    DataSet ds = bll.GetAllList();
            //    ddlproject.DataSource = ds.Tables[0];
            //    ddlproject.DataTextField = "projectName";
            //    ddlproject.DataValueField = "projectId";
            //    ddlproject.DataBind();
            //}

        }
        public void BindData()
        {            
            DataSet ds = new DataSet();

            //int projectId = int.Parse(ddlproject.SelectedValue);

            string where ="";
            if(txtSearch.Text.Trim()!="")
            where+= " and projectname='" + txtSearch.Text.Trim()+"'";

            if (!string.IsNullOrEmpty(this.txt_material.Text))
            {
                where += " and material like '%"+txt_material.Text+"%' ";
            }
            if (!string.IsNullOrEmpty(this.txtDDH.Text.Trim()))
            {
                where += " and purchaseid = '" + txtDDH.Text.Trim() + "' ";
            }

            ds = bs.GetListnumsbyid(where);
            if (ds.Tables[0].Rows.Count > 0)
            {                
                //lh1.Text = "共有" + ds.Tables[0].Rows.Count.ToString() + "条";
                lt0.Text = "";
                lt1.Text = "";
                lt2.Text = "";
                lt3.Text = "";
                lt4.Text = "";
                lt5.Text = "";
                lt6.Text = "";

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (i != ds.Tables[0].Rows.Count - 1)
                    {
                        lt0.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["num"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["supplyPDate"].ToString() + "<br />";
                        lt1.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["thisMonthCount"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["supplyDate"].ToString() + "<br />";
                        lt2.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["nums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["ddate"].ToString() + "<br />";
                        lt3.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["aognums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["lastArrivalDate"].ToString() + "<br />";
                        lt4.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["pinums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["lastCheckedDate"].ToString() + "<br />";
                        lt5.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["innums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["lastInstoreDate"].ToString() + "<br />";
                        lt6.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["outnums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["lastouttime"].ToString() + "<br />";                        
                    }
                    else
                    {
                        lt0.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["num"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["supplyPDate"].ToString()  ;
                        lt1.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["thisMonthCount"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["supplyDate"].ToString() ;
                        lt2.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["nums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["ddate"].ToString() ;
                        lt3.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["aognums"].ToString()+ " 时间：" + ds.Tables[0].Rows[i]["lastArrivalDate"].ToString()  ;
                        lt4.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["pinums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["lastCheckedDate"].ToString() ;
                        lt5.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["innums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["lastInstoreDate"].ToString();
                        lt6.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["outnums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["lastouttime"].ToString() ;                        
                    }
                }                
            }            
        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            BindData();
        }

    }
}